package Unicart.pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

public class MainPage extends AnyPage {

	public MainPage(PageManager pages) {
		super(pages);
	}

  @FindBy(linkText = "Войти")
  //css = "b-page-content_in a[href $= 'login']"
  private WebElement enterLink;
  
  @FindBy(linkText = "Регистрация")
  //css = "b-page-content_in a[href $= 'registration']"
  private WebElement registrationLink;

  @FindBy(linkText = "Забыли пароль?")
  //css = "b-page-content_in a[href $= 'forgot-password']"
  private WebElement forgotPasswordLink;
  
  public MainPage ensurePageLoaded() {
    super.ensurePageLoaded();
    wait.until(presenceOfElementLocated(By.linkText("Регистрация")));
    return this;
  }
  
  public LoginPage clickEnterLink() {
	enterLink.click();
	return pages.loginPage;
  }
  
  public RegistrationPage clickRegistrationLink() {
	registrationLink.click();
	return pages.registrationPage;
  }
  
  public ForgotPasswordPage clickForgotPasswordLink() {
	forgotPasswordLink.click();
	return pages.forgotPasswordPage;
  }
}
